package com.demo.flink

import org.apache.flink.api.scala.{ExecutionEnvironment, createTypeInformation}

object WordCount {
  def main(args: Array[String]): Unit = {
    val env = ExecutionEnvironment.getExecutionEnvironment
    val lines = env.fromElements(
      "Flink Spark Storm",
      "Flink Flink Flink",
      "Hadoop Hive Hbase",
      "Storm Spark Streaming Flink"
    )
    val counts = lines.flatMap(s=>s.split(" "))
      .map(word=>WordWithCount(word,1))
      .groupBy(0)
      .sum(1)
    counts.printToErr()
  }

  case class WordWithCount(word: String, count: Long)
}
